local zishucup__nilang = fk.CreateSkill{
  name = "zishucup__nilang",
}

Fk:loadTranslationTable{
  ["zishucup__nilang"] = "逆浪",
  [":zishucup__nilang"] = "当前回合角色使用【杀】或装备牌后，你可以摸一张牌，然后你选择一项：使用另一种牌（无距离次数限制）；或失去1点体力。",

  ["#zishucup__nilang-invoke1"] = "逆浪：是否摸一张牌，若摸牌，你须使用【杀】（无距离次数限制）或失去1点体力。",
  ["#zishucup__nilang-invoke2"] = "逆浪：是否摸一张牌，若摸牌，你须使用装备牌或失去1点体力。",
  ["#zishucup__nilang1"] = "逆浪：请使用【杀】（无距离次数限制），或失去1点体力。",
  ["#zishucup__nilang2"] = "逆浪：请使用装备牌，或失去1点体力。",

  ["$zishucup__nilang1"] = "千浪万壑，吾亦逐而踏之！",
  ["$zishucup__nilang2"] = "速讨山越草寇，以备北境之患！",
}

zishucup__nilang:addEffect(fk.CardUseFinished, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(zishucup__nilang.name) and player.room.current and target == player.room.current then
      return data.card.type == Card.TypeEquip or data.card.trueName == "slash"
    end
  end,
  on_cost = function(self, event, target, player, data)
    if data.card.type == Card.TypeEquip then
      return player.room:askToSkillInvoke(player, { skill_name = zishucup__nilang.name, prompt = "#zishucup__nilang-invoke1",})
    elseif data.card.trueName == "slash" then
      return player.room:askToSkillInvoke(player, { skill_name = zishucup__nilang.name, prompt = "#zishucup__nilang-invoke2",})
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, zishucup__nilang.name)
    if not player.dead then
      if data.card.type == Card.TypeEquip then
        local use = room:askToUseCard(player, {
          skill_name = zishucup__nilang.name,
          pattern = "slash",
          prompt = "#zishucup__nilang1",
          extra_data = {
            bypass_times = true,
            bypass_distances = true,
            extraUse = true,
          },
          cancelable = true,
        })
        if use then
          use.extraUse = true
          room:useCard(use)
        else
          room:loseHp(player, 1, zishucup__nilang.name)
        end
      elseif data.card.trueName == "slash" then
        local use = room:askToUseCard(player, {
          skill_name = zishucup__nilang.name,
          pattern = ".|.|.|.|.|equip",
          prompt = "#zishucup__nilang2",
          extra_data = {
            bypass_times = true,
            bypass_distances = true,
            extraUse = true,
          },
          cancelable = true,
        })
        if use then
          use.extraUse = true
          room:useCard(use)
        else
          room:loseHp(player, 1, zishucup__nilang.name)
        end
      end
    end
  end,
})

return zishucup__nilang
